home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / rexx / 41 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.7 KB

  1. Path: news-m01.ny.us.ibm.net!usenet
  2. From: oraeder@ibm.net
  3. Newsgroups: comp.lang.rexx
  4. Subject: Re: Need date routine
  5. Date: 3 Jan 1996 09:32:58 GMT
  6. Distribution: inet
  7. Message-ID: <4cdiga$grq@news-s01.ny.us.ibm.net>
  8. References: <4b9e9v$9j5@blackice.winternet.com> <VA.00000019.00050e2b@slip139-92-17-135.emea.ibm.net>
  9. Reply-To: oraeder@ibm.net
  10. NNTP-Posting-Host: slip139-92-41-11.emea.ibm.net
  11. X-Newsreader: IBM NewsReader/2 v1.2
  12.  
  13. In <VA.00000019.00050e2b@slip139-92-17-135.emea.ibm.net>, ProMicro Limited, London <promico@ibm.net> writes:
  14. >> I need a date routine which will allow me to give it a julian date and 
  15. >> give me back the mm/dd/yy.  Other computations would also be useful but I 
  16. >> need the above for a project I'm working on.  Please email to 
  17. >> sluce@winternet.com.  Thanks!
  18. >
  19. >Please post here in sted, there are more people intrested.
  20. >
  21. >
  22. >
  23. >
  24. i was offering to sluce a dll which does the thing, however he needs 
  25. the stuff for VM.
  26. i was extracting these two routines and recoded it in rexx:
  27.  
  28. ----------------------------------------------------------------------
  29. dat2jul.cmd
  30.  
  31. /* ----------------------------------------------------------------- */
  32. /*                             ** Julian Day, Montenbruck p. 50      */
  33.    parse arg y m d .      
  34.  
  35.    g1  = 15821004              /*  greg-jul calendar correction      */
  36.    g2  = 15821015
  37.  
  38.    gw = y*10000 + m*100 + d;
  39.    if (gw>g1)&(gw<g2) then                                    return 0 
  40.    if m>2 then do; yy=y;   mm=m;    end
  41.           else do; yy=y-1; mm=m+12; end  
  42.    if gw<=g1 then b=-2 
  43.              else b=yy%400-yy%100 
  44.    jul=(365.25*yy)%1+(30.6001*(mm+1))%1+b+1720996+d+.5;
  45.                                                                         return jul 
  46. ---------------------------------------------------------------------------
  47. jul2dat.cmd
  48.  
  49.  
  50. /* ----------------------------------------------------------------- */
  51. /*                            ** Kalender-Date, Montenbruck p. 51    */
  52. /*                               nicht sauber wenn jahr<0            */
  53.    parse arg jul '.' .
  54.                            a = jul+1
  55.                            b=0
  56.    if  a<2299161 then      c = a+1524
  57.                  else  do; b = ((a-1867216.25)/36524.25)%1  
  58.                            c = 1525+a+b-b%4
  59.                            end  
  60.                            d = ((c-122.1)/365.25)%1
  61.                            e = (d*365.25)%1
  62.                            f = ((c-e)/30.6001)%1
  63.    mm =  f-1-12*((f/14)%1)
  64.    yy =  d-4715-(((7+mm)/10)%1)
  65.    dd =  c-e-((f*30.6001)%1)-1*(yy<0)
  66.     
  67.    dat = yy'-'right(mm+100,2)'-'right(dd+100,2)
  68.                                                            return dat
  69. -------------------------------------------------------------------------
  70. hope that helps
  71.  
  72. otto raeder
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.